﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.IO;


namespace BeerManagementSystem
{
    /// <summary>
    /// Interaktionslogik für logForm.xaml
    /// </summary>
    public partial class LogForm : UserControl

    {
        private StreamReader _streamReader;

        public LogForm(StreamReader streamReader)
        {
            InitializeComponent();
            _streamReader = streamReader;
            ReadOutLogfile(_streamReader);
        }

        private void ReadOutLogfile( StreamReader reader)
        {
                try
                {
                    string line;

                    while ((line = reader.ReadLine()) != null)
                    {
                        listBox.Items.Add(line);
                    }
                    reader.Close();
                    listBox.ScrollIntoView(listBox.Items[listBox.Items.Count - 1]);
                }
                catch (Exception e)
                {
                    Console.WriteLine(e.InnerException + e.StackTrace);
                }
        }
    }
}
